#include <iostream>
#include <string.h>
#include <set>
using namespace std;

void test(){
    //无参构造函数
    set<int> number;

    //传参迭代器的方式
    int arr[5]={1,2,3,4,5};
    set<int> number2(arr,arr+5);

    //拷贝构造函数
    set<int>number3=number2;

    //初始化列表的方式
    set<int>number4{1,2,3,4,5,6,7,8};

    //遍历
    //增强for循环
    for(auto &ele:number4){
        cout<<ele<<endl;
    }
    auto it1=number4.begin();
    auto it2=number4.end();
    while(it1!=it2){
    cout<<*it1<<endl;
    it1++;
    }
}


bool is_exist(const set<int> num,const int& key){
    size_t count=num.count(key);
    return count==1;
}
bool is_exist2(const set<int> num,const int& key){
    auto result=num.find(key);
    if(result==num.end()){
        return false;
    }
    cout<<*result<<endl;
    return true;
}
void test2(){
    set<int>number{1,2,3,4,5,6};
    cout<<is_exist(number,2)<<endl;
    cout<<is_exist(number,9)<<endl;
    cout<<is_exist2(number,2)<<endl;
    cout<<is_exist2(number,9)<<endl;
}
void test3(){
    pair<string,int>frequency("the",1);
    cout<<frequency.first<<":"<<frequency.second<<endl;
    set<int> number{1,2,3,4,5,6,7,8};
    auto result=number.insert(10);
    if(result.second){
        cout<<"插入元素是"<<*result.first<<endl;
    }else{
        cout<<"插入失败"<<endl;
    }
    int arr[6]={11,23,44,76,6,10};
    number.insert(arr,arr+6);
    for(auto& ele:number){
        cout<<ele<<endl;
    }
    number.insert(arr,arr+6);
    for(auto& ele:number){
        cout<<ele<<endl;
    }

    number.insert({34,234,345,65});
    for(auto &ele: number){
        cout<<ele<<endl;
    }
}
void test4(){
    pair<string,int> prices;
    prices.first=("apple");

}
int main(int argc, char * argv[]){
    test2();
    test3();
    return 0;
}

